/*
 * @Description:
 * @Author: mtt
 * @Date: 2023-07-16 18:21:24
 * @LastEditTime: 2023-07-16 19:09:03
 * @LastEditors: mtt
 * @Reference:
 * @FilePath: \react-my-website-master\src\page\home\components\footer\index.js
 */
import React, { Component } from 'react';
import { footer } from '../../home.scss';
/**
 * @name home页面的页脚
 */
export default class HomeFooter extends Component {
  constructor() {
    super();
    this.state = {
      ...this.initDateState()
    }
    setInterval(() => {
      const timer = this.initDateState()
      this.setState({
        dateValue: timer.dateValue,
        timeValue: timer.timeValue
      })
    }, 1000);
  }

  initDateState() {
    const date = new Date();
    const dateValue =
      ' Date = ' +
      date.getFullYear() +
      '/' +
      (+date.getMonth() + 1) +
      '/' +
      date.getDate();

    const usedTime = window.__START_DATE__
      ? (date.getTime() - window.__START_DATE__) / 1000
      : 3;
    const timeValue = usedTime > 1 ? Math.ceil(usedTime) : usedTime.toFixed(1);

    return {
      dateValue,
      timeValue,
    };
  }

  render() {
    const { dateValue, timeValue } = this.state;

    return (
      <footer className={footer}>
        <ul id='footer'>
          <li style={{color:'#fff'}}>
            <b>const</b>
            {dateValue}
          </li>
          <li style={{color:'#fff'}}>
            <b>const</b> UseTime = {timeValue}s
          </li>
          <li style={{color:'#fff'}}>
            <b>const</b> Add=山东省济南
          </li>
          <li style={{color:'#fff'}}>WWW.jkhr.xyz</li>
          <li style={{color:'#fff'}}>
            <a target="_blank" href="http://www.jkhr.xyz">
              个人网站还没审核通过
            </a>
          </li>
        </ul>
      </footer>
    );
  }
}
